package com.sky.utils;
import java.util.Random;

public class RandomCodeUtil {
    // 可选字符（字母 + 数字）
    private static final String CHAR_SET = "ABCDEFghijk0123456789";

    public static String getCode(int length) {
        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);

        for (int i = 0; i < length; i++) {
            // 从 CHAR_SET 中随机选一个字符
            int randomIndex = random.nextInt(CHAR_SET.length());
            sb.append(CHAR_SET.charAt(randomIndex));
        }

        return sb.toString();
    }
}
